package main.java.com.example.demo.service;

import com.example.demo.mapper.UserMapper;
import com.example.demo.pojo.User;
import com.example.demo.util.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @Description:
 * @Param:
 * @Author:
 * @Date:
 */
@Service
public class UserService {

    @Autowired
    private UserMapper userMapper;

    public User findUser(User user){
        User userInfo = userMapper.findUser(user);
        if(userInfo == null){
            userInfo = new User();
            userInfo.setId(0);
            return userInfo;
        }
        return userInfo;
    }

    public void insertUser(User user) {
        user.setCreateTime(DateUtil.getDateTimeStringYYYY(new Date()));
        user.setRole("0");
        userMapper.insertUser(user);
    }


    public List<User> findAllUser() {
        return userMapper.findAllUser();
    }

    public void delUser(User user) {
        userMapper.delUser(user);
    }
}
